Fix a minor issue with the datepicker.#2944
Open
drgrice1 wants to merge 1 commit intoopenwebwork:WeBWorK-2.21from
Open
Fix a minor issue with the datepicker.#2944drgrice1 wants to merge 1 commit intoopenwebwork:WeBWorK-2.21from
drgrice1 wants to merge 1 commit intoopenwebwork:WeBWorK-2.21from
Conversation
somiaj
approved these changes
Apr 7, 2026
With the current code if you are in a month that does not have a day (such as April that does not have the 31st), one of those days is selected in another month that does have that day, and you click the "Today" button, then it doesn't go to today. Instead it goes to the date of today in the next month. This is because the code sets the year, month, and day for today on the selected date object and in that order, and uses the modified selected date to set the flatpickr date. So for example, if today is April 7, 2026, and the selected date is July 31, 2026, then the selected date's year is set to 2026, then the month set to April. So at that point the selected date is April 31, 2026, which really becomes May 1, 2026. Then the day is set, and so you get May 7, 2026. This fixes the issue by starting with todays date at 12:00 am, and then setting the time of todays date to the time of the selected date, and then using that to set the flatpickr date.
70187c6 to
df014ba
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With the current code if you are in a month that does not have a day (such as April that does not have the 31st), one of those days is selected in another month that does have that day, and you click the "Today" button, then it doesn't go to today. Instead it goes to the date of today in the next month. This is because the code sets the year, month, and day for today on the selected date object and in that order, and uses the modified selected date to set the flatpickr date. So for example, if today is April 7, 2026, and the selected date is July 31, 2026, then the selected date's year is set to 2026, then the month set to April. So at that point the selected date is April 31, 2026, which really becomes May 1, 2026. Then the day is set, and so you get May 7, 2026.
This fixes the issue by starting with todays date at 12:00 am, and then setting the time of todays date to the time of the selected date, and then using that to set the flatpickr date.